package searchTests;

import java.util.ArrayList;
import java.util.Random;

import sortTests.QuickSort;

public class SearchTestsMain {

	public static void main(String[] args) {
		int size = 10000;
		int tries = 200;
		for (int a = 0; a < tries; a++) {
			if (tries > 10) if (a % (tries / 10) == 0) System.out.print(".");
			ArrayList<Integer> array = new ArrayList<Integer>();
			Random random = new Random();
			for (int i = 0; i < size; i++) {
				array.add(random.nextInt(size*10));
			}
			//System.out.println(array);
						
			QuickSort sort = new QuickSort();
			sort.sort(array);
			
			//System.out.println(array);
			
			int toFind = array.get(random.nextInt(size));
			//System.out.println(toFind);
			
			ISearch search = new BinSearch();
			int index = search.search(array, toFind);
			//System.out.println(index);
			if (index != -1) if (array.get(index) != toFind) {
				System.out.println("FAIL");
				System.out.println(array);
				System.out.println("To find:"+toFind);
				System.out.println("Found i:"+index);
				System.out.println("At i:"+array.get(index));
				return;
			}
		}
		System.out.println("Done");
	}

}
